<?php
/**
 * Class descript.
 * User: chan
 * Date: 2017/8/16 18:26
 */
namespace WeChat;

class Menu
{
    const API_CREATE = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=%s';
    const API_GET = 'https://api.weixin.qq.com/cgi-bin/menu/get?access_token=%s';
    const API_DELETE = 'https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=%s';
    private static $access_token = "";
    public function __construct($options)
    {
        $AccessToken = new AccessToken($options);
        self::$access_token = $AccessToken->access_token;
    }

    /**
     * 查询菜单
     */
    public function all()
    {

    }
    /**
     * 添加菜单
     */
    public function add()
    {
        $buttons = ' {
                         "button":[
                         {	
                              "type":"click",
                              "name":"今日歌曲",
                              "key":"V1001_TODAY_MUSIC"
                          },
                          {
                               "name":"菜单",
                               "sub_button":[
                               {	
                                   "type":"view",
                                   "name":"搜索",
                                   "url":"http://www.soso.com/"
                                },
                                {
                                   "type":"click",
                                   "name":"赞一下我们",
                                   "key":"V1001_GOOD"
                                }]
                           }]
                     }';

        return httpRequest(sprintf(self::API_CREATE,self::$access_token),'POST',$buttons);
    }

    /**
     * 删除指定菜单
     * @param $menuId int 菜单ID
     */
    public function destroy($menuId = null)
    {

    }

}